<%@include file="/pub/import.jsp"%>
<%@include file="/pub/header.jsp"%>
<%
    int projectId = RequestUtil.getIntParameter(request,"id",0);
    Project project = ProjectHandler.getProject(projectId);
    ScoreTree tree = ScoreTreeHandler.loadById(RequestUtil.getIntParameter(request,"treeId",1));
    ScoreTree controlTree = ScoreTreeHandler.getControlTreeByTree(tree.getId());
    Map<Integer, List<ProjectItems>> tmpItem = (Map<Integer,List<ProjectItems>>) request.getSession().getAttribute("tmp_projectitem");
    List<ProjectItems> list = new ArrayList<ProjectItems>();;
    if(tmpItem!=null && tmpItem.containsKey(tree.getId())) {
      list = tmpItem.get(tree.getId());      
    }
    Map<Integer,Float> itemScoreMap = new HashMap<Integer,Float>();
    for(int i=0; i<list.size(); i++) {
      itemScoreMap.put(list.get(i).getScoreItem().getId(),list.get(i).getScore());
    }
    context.put("itemScoreMap", itemScoreMap);
    if(controlTree!=null) {
      context.put("percent", controlTree.getPercent());
    }else{
      context.put("percent", 0);
    }
    String ignoreIds = "";
    if(StringUtils.isEmpty(project.getBuildUnit())) ignoreIds += "1,";
    if(StringUtils.isEmpty(project.getConstructUnit())) ignoreIds += "3,";
    //if(StringUtils.isEmpty(project.getBuildUnit())) ignoreIds += "1";
    //if(StringUtils.isEmpty(project.getBuildUnit())) ignoreIds += "1";
    ignoreIds = StringUtil.cutLastComm(ignoreIds);
    context.put("cateTree", ScoreTreeHandler.getTreeOptionString(ignoreIds));
    context.put("scoreTree", tree);
    context.put("itemList", tree.getScoreItems());
    context.put("projectId", projectId);
    out.println(TemplateUtil.getOutput(context,"/view/project/addNewProject_StepTwo.html"));
%>
<%@include file="/pub/footer.jsp"%>